package com.aduerr.v1shouyin.unioncard;

import android.content.Intent;
import android.util.Log;
import android.widget.TextView;

import com.aduerr.v1shouyin.R;

import java.text.SimpleDateFormat;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author HI
 * @email dev1024@foxmail.com
 * @time 2019/7/13 16:26
 * @change
 * @chang 2020/02/28
 * @class 乐刷换了sdk，这个Activity没用了
 */

public class UnionReadCardActivity extends BaseUnionActivity {

    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_consume_money)
    TextView tvConsumeMoney;
    @BindView(R.id.tv_card_no)
    TextView tvCardNo;
    @BindView(R.id.tv_pay_moeny)
    TextView tvPayMoeny;

    String money;
    long amount;
    int type; //1:消费，2：退款
    private String orderId;
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    @Override
    protected int getLayoutId() {
        return R.layout.activity_union_read_card;
    }

    @Override
    protected void initBase() {
        super.initBase();
        ButterKnife.bind(this);

//        if(!sdf.format(new Date()).equals(sdf.format(posTradeInfoManage
//        .getLastSignTime()))) {
//            sign();
//        } else {
//            initData();
//        }

    }

    private void initData() {
        money = getIntent().getStringExtra("money");
        float f = Float.parseFloat(money);
        float f2 = f * 100;
        amount = (long) f2;
        type = getIntent().getIntExtra("type", 0);
        if(type == 1) {
            tvTitle.setText("消费");
            orderId = getIntent().getStringExtra("orderId");
        } else if(type == 2) {
            tvTitle.setText("退款");
        }
        tvConsumeMoney.setText(money);
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode == 86) {
            initData();
        }
    }



    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }

    /**
     * @param txt toast文案
     */
    private void promptText(final String txt) {
        runOnUiThread(() -> showToast(txt));
    }
}
